﻿using System;
using System.Runtime.Serialization;
using System.Linq.Expressions;

namespace ExpressionSerialization
{
  [DataContract]
  public class XUnaryExpression : XExpression
  {

    [DataMember]
    public XExpression Operand { get; set; }

    public override void FromExpression(Expression source_)
    {
      base.FromExpression(source_);
      UnaryExpression unexp = source_ as UnaryExpression;
      Operand = XExpression.CreateFromExpression(unexp.Operand);
    }

    public override Expression ToExpression(Type dataContract_, System.Collections.Generic.List<ParameterExpression> parameters_)
    {
      return Expression.MakeUnary(NodeType, Operand.ToExpression(dataContract_,parameters_), this.GetExpressionType(dataContract_));
    }

  }
}
